package com.wyix.properties;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;

/**
 * 权限认证配置属性类，用于接收application.properties中的配置
 */
@ConfigurationProperties(prefix = "company.auth")
public class AuthProperties {
    /**
     * 应用ID
     */
    private String appId;

    /**
     * 应用密钥
     */
    private String secret;

    /**
     * Token过期时间，默认2小时
     */
    private Duration tokenExpireTime = Duration.ofHours(2);

    /**
     * 刷新Token过期时间，默认7天
     */
    private Duration refreshTokenExpireTime = Duration.ofDays(7);

    /**
     * 需要拦截的路径，默认/api/**
     */
    private List<String> includePaths = new ArrayList<>() {{
        add("/api/**");
    }};

    /**
     * 不需要拦截的路径
     */
    private List<String> excludePaths = new ArrayList<>() {{
        add("/api/public/**");
        add("/api/auth/login");
        add("/api/auth/refresh");
    }};

    /**
     * 是否启用权限认证，默认true
     */
    private boolean enabled = true;

    // getter和setter方法
    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public Duration getTokenExpireTime() {
        return tokenExpireTime;
    }

    public void setTokenExpireTime(Duration tokenExpireTime) {
        this.tokenExpireTime = tokenExpireTime;
    }

    public Duration getRefreshTokenExpireTime() {
        return refreshTokenExpireTime;
    }

    public void setRefreshTokenExpireTime(Duration refreshTokenExpireTime) {
        this.refreshTokenExpireTime = refreshTokenExpireTime;
    }

    public List<String> getIncludePaths() {
        return includePaths;
    }

    public void setIncludePaths(List<String> includePaths) {
        this.includePaths = includePaths;
    }

    public List<String> getExcludePaths() {
        return excludePaths;
    }

    public void setExcludePaths(List<String> excludePaths) {
        this.excludePaths = excludePaths;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }
}
